package com.qf.controller;

import com.qf.vo.ResultVO;
import org.quartz.JobKey;
import org.quartz.SchedulerException;
import org.quartz.impl.StdScheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
//控制定时任务
@RestController
@RequestMapping("/tast")
public class TastController {
    @Autowired
    private StdScheduler stdScheduler;

    @GetMapping("/suspend")
    //暂停任务    //传过来要停止的任务名称，任务分组
    public ResultVO suspend(String jobName, String groupName) throws SchedulerException {
        //暂定任务
        stdScheduler.pauseJob(JobKey.jobKey(jobName, groupName));
        ResultVO resultVO=new ResultVO();
        return resultVO;
    }

    @GetMapping("/recovery")
    //启动任务
    public ResultVO recovery(String jobName, String groupName) throws SchedulerException {
        stdScheduler.resumeJob(JobKey.jobKey(jobName, groupName));
        ResultVO resultVO=new ResultVO();
        return  resultVO;
    }

}
